/*
	@author : "likaituan",
	@email : "61114579@qq.com",
	@version : "4.0",
	@date : "2010-09-05",
	@lastime : "2011-8-18"
*/


//检测碰撞
//例如：F.iscross({x1:480,y1:0,x2:520,y2:40},{x1:480,y1:10,x2:40,y2:50});
F.iscross = function(o1,o2){
	if(o1.x1==o2.x1&&o1.x2==o2.x2&&(o1.y1>o2.y1&&o1.y1<o2.y2||o1.y2>o2.y1&&o1.y2<o2.y2))return true;
	if(o1.y1==o2.y1&&o1.y2==o2.y2&&(o1.x1>o2.x1&&o1.x1<o2.x2||o1.x2>o2.x1&&o1.x2<o2.x2))return true;
	if(o1.x1==o2.x1&&o1.x2==o2.x2&&o1.y1==o2.y1&&o1.y2==o2.y2)return true;
	var a = [ [o2.y1,o2.x1], [o2.y1,o2.x2], [o2.y2,o2.x1], [o2.y2,o2.x2] ];
	var y,x;
	for(var i=0; i<4; i++){
		y=a[i][0], x=a[i][1];
		if(y>o1.y1&&y<o1.y2&&x>o1.x1&&x<o1.x2) return true;
	}
	return false;
};


//冒泡算法
F.bubble = function(a){
    for(var i=a.length-1; i>0; i--){
        for(var j=0; j<i; j++){
            a[j]>a[i] && a.swap(i,j);
        }
    }
	return a;
}